<template>
    <div class="mySwiper">
        <van-swipe :autoplay="3000" lazy-render>
            <van-swipe-item v-for="image in images.list" @click="pathGo(image)" :key="image">
                <img :src="'https://images.weserv.nl/?url=' + image.index_image_url" />
            </van-swipe-item>
        </van-swipe>
        <van-dialog v-model:show="show" title="这只是广告" show-cancel-button> </van-dialog>
    </div>
</template>
<script setup>
import { reactive, ref } from "vue";
import { newsDetail, undateUserWeb } from "@/request/index";

import { Dialog } from "vant";
const images = reactive({ list: [] });
import { useRouter } from "vue-router";
let router = useRouter();

const show = ref(false);
newsDetail().then((res) => {
    // console.log(res.rows, "newsDetail");
    let dd = res.rows.filter((item) => {
        return item.hot == 1;
    });
    console.log(dd, "dd");
    // index_image_url
    images.list = dd;
});
// bannerList().then((data) => {
//     console.log(data);
//     images.list = data.result;
// });
let user_id = localStorage.getItem("token");

const pathGo = (x) => {
    console.log(x);
    router.push({ path: "/newsDetail", query: { id: x.id } });
    undateUserWeb({ user_id, comment_db: "comment", comment_id: x.id, comment: x.digest }).then((data) => {
        // console.log("undateUserWeb", data);
    });
};
// const pageGo = () => {
//     show.value = true;
// };
</script>
<style lang="scss">
.mySwiper {
    padding: 10px;
    .van-swipe-item {
        height: 4.5333rem;
    }
    img {
        width: 100%;
        background: url(@/static/images/jjz.webp) no-repeat center center;
        background-size: cover;
    }
    .van-swipe__indicator--active {
        background-color: #576574;
    }
    .van-dialog__confirm,
    .van-dialog__confirm:active {
        color: #f15a24;
    }
}
</style>
